<template>
  <div class="header">
    <div class="header-left">
      <el-icon @click="foldMenu"><expand /></el-icon>
      <span>系统总览 / 项目概述</span>
    </div>
    <div class="header-user">
      <div class="header-user-icons">
        <el-avatar
          :size="30"
          src="https://tse4-mm.cn.bing.net/th/id/OIP-C.Akgn7IGD6Qjh-VOgZ61LdwHaGl?pid=ImgDet&rs=1"
        ></el-avatar>
      </div>
      <el-dropdown>
        <span class="el-dropdown-link">
          {{ name }}
          <el-icon class="el-icon--right">
            <arrow-down />
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>退出登陆</el-dropdown-item>
            <el-dropdown-item>用户信息</el-dropdown-item>
            <el-dropdown-item>系统管理</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue'
import { useStore } from '@/store'

export default defineComponent({
  name: 'Header',
  emits: ['foldMenu'],
  setup (_, { emit }) {
    const store = useStore()
    const name = computed(() => store.state.login.userInfo.name)
    const foldMenu = () => {
      emit('foldMenu')
    }
    return { foldMenu, name }
  }
})
</script>

<style scoped lang="less">
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  .header-left {
    display: flex;
    align-items: center;
    height: 100%;
    cursor: pointer;
    .el-icon {
      font-size: 30px;
      margin-right: 10px;
    }
  }
  .header-user {
    display: flex;
    justify-content: center;
    align-items: center;
    .header-user-icons {
      height: 100%;
    }
    .el-dropdown {
      margin-left: 4px;
      cursor: pointer;
      :deep(.el-icon--right) {
        display: inline-block;
        transform: translateY(3px);
      }
    }
  }
}
</style>
